<?php

namespace App\Observers;
use App\Jobs\SendFangownerMail;
use App\Models\Fangowner;
use Mail;
use Illuminate\Mail\Message;

//观察类
class FangownerObserver
{
    //事件的方法
    //添加成功后事件方法
    public function created(Fangowner $fangowner)
    {
//        Mail::raw('您的信息在本平台添加成功', function (Message $message) use ($fangowner) {
//            $message->to($fangowner->email, $fangowner->name);
//            $message->subject('添加成功通知');
//        });

        //把发送邮件的任务添加到任务记录表
        dispatch(new SendFangownerMail($fangowner));
    }
}
